package com.sun.aop.handler;

import com.sun.aop.util.BeanTool;

import java.util.Map;

/**
 * @Author 喻湘东
 * @Create 2019-09-22 17:42:11
 */
public class HandlerContext {

    private Map<String,Class> handlerMap;

    public HandlerContext(Map<String, Class> handlerMap) {
        this.handlerMap = handlerMap;
    }

    public AbstractHandler getInstanc(String methodName){
        Class clazz = handlerMap.get(methodName);
        if(clazz==null){
            throw new RuntimeException("not found handler for methodName："+methodName);
        }
        return (AbstractHandler) BeanTool.getBean(clazz);
    }

}
